package com.zhai.test.domain.award;

import com.zhai.domain.award.model.entity.DistributeAwardEntity;
import com.zhai.domain.award.model.entity.UserAwardRecordEntity;
import com.zhai.domain.award.model.valobj.AwardStateVO;
import com.zhai.domain.award.service.AwardService;
import com.zhai.domain.award.service.IAwardService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @Description:
 * @ClassName: AwardTest
 * @Author: zhaiyongxin
 * @Date: 2025/3/6 20:16
 * @Version: 1.0
 */
@SpringBootTest
@Slf4j
@RunWith(SpringRunner.class)
public class AwardServiceTest {

    @Resource
    private IAwardService awardService;

    @Test
    public void test_saveUserAwardRecord() {
        UserAwardRecordEntity userAwardRecordEntity = new UserAwardRecordEntity();
        userAwardRecordEntity.setUserId("zhaiyongxin");
        userAwardRecordEntity.setAwardId(101);
        userAwardRecordEntity.setActivityId(100301L);
        userAwardRecordEntity.setStrategyId(100006L);
        userAwardRecordEntity.setAwardTitle("OpenAI 增加模型");
        userAwardRecordEntity.setAwardState(AwardStateVO.create);
        userAwardRecordEntity.setAwardTime(new Date());
        userAwardRecordEntity.setOrderId(RandomStringUtils.randomNumeric(12));
        awardService.saveUserAwardRecord(userAwardRecordEntity);
    }

    @Test
    public void test_distributeAward() {
        DistributeAwardEntity distributeAwardEntity = new DistributeAwardEntity();
        distributeAwardEntity.setAwardId(101);
        distributeAwardEntity.setOrderId("244661423978");
        distributeAwardEntity.setAwardConfig("1,100");
        distributeAwardEntity.setUserId("zhaiyongxin");
        awardService.distributeAward(distributeAwardEntity);
    }
}
